<%@page import="java.util.LinkedList"%>
<%@page import="java.util.List"%>
<%@page import="entities.Feedback"%>
<%@page import="entities.Skill"%>
<%@page import="entities.User"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>MyProfile</title>
<style type="text/css">
<!--
a:link {
	text-decoration: none;
	color: #FFFF99
}

a:visited {
	text-decoration: none;
	color: #FFFF99
}

a:hover {
	color: skyblue
}
-->
</style>
</head>
<body background="images/gradient.png" bgproperties="fixed">
	<!-- <h1>MY PROFILE</h1> -->
	<div align="center">
		<img src="images/header.png">
	</div>
	<div align="center">
		<table width="1000" bgcolor="#4956B1">
			<tr>
				<%
					if (session.getAttribute("username") == null) {
				%>
				<td align="center" valign="middle" width="50" height=""><font
					face="tahoma" color="#FFFF99" size="2"><b><a
							href="home.jsp">&nbsp;&nbsp;HOME&nbsp;&nbsp;</a></b></font></td>
				<td align="center" valign="middle" width="50" height=""><font
					face="tahoma" color="#FFFF99" size="2"><b><a
							href="register.jsp">&nbsp;&nbsp;REGISTRAZIONE&nbsp;&nbsp;</a></b></font></td>
				<td align="center" valign="middle" width="50" height=""><font
					face="tahoma" color="#FFFF99" size="2"><b><a
							href="search.jsp">&nbsp;&nbsp;RICERCA&nbsp;&nbsp;</a></b></font></td>
				<td></td>
				<%
					} else {
				%>
				<%
					if (session.getAttribute("admin") == null) {
				%>
				<td align="center" valign="middle" width="50" height=""><font
					face="tahoma" color="#FFFF99" size="2"><b><a
							href="home.jsp">&nbsp;&nbsp;HOME&nbsp;&nbsp;</a></b></font></td>
				<td align="center" valign="middle" width="50" height=""><font
					face="tahoma" color="#FFFF99" size="2"><b><a
							href="./MyProfile">&nbsp;&nbsp;PROFILO&nbsp;&nbsp;</a></b></font></td>
				<td align="center" valign="middle" width="50" height=""><font
					face="tahoma" color="#FFFF99" size="2"><b><a
							href="./Friends">&nbsp;&nbsp;AMICI&nbsp;&nbsp;</a></b></font></td>
				<td align="center" valign="middle" width="50" height=""><font
					face="tahoma" color="#FFFF99" size="2"><b><a
							href="./FriendshipReqs">&nbsp;&nbsp;AMICIZIE&nbsp;&nbsp;</a></b></font></td>
				<td align="center" valign="middle" width="50" height=""><font
					face="tahoma" color="#FFFF99" size="2"><b><a
							href="./HelpReqs">&nbsp;&nbsp;AIUTI&nbsp;&nbsp;</a></b></font></td>
				<td align="center" valign="middle" width="50" height=""><font
					face="tahoma" color="#FFFF99" size="2"><b><a
							href="./SkillReqs">&nbsp;&nbsp;ABILITA'&nbsp;&nbsp;</a></b></font></td>
				<td align="center" valign="middle" width="50" height=""><font
					face="tahoma" color="#FFFF99" size="2"><b><a
							href="search.jsp">&nbsp;&nbsp;RICERCA&nbsp;&nbsp;</a></b></font></td>
				<td></td>
				<td align="right" valign="middle" width="150" height=""><font
					face="tahoma" color="#FFFF99" size="2">&nbsp;&nbsp;Ciao, <%=session.getAttribute("username")%>!
						<a href="./Logout"><b>LOGOUT&nbsp;&nbsp;</b></a></font></td>
				<%
					} else {
				%>
				<td align="center" valign="middle" width="50" height=""><font
					face="tahoma" color="#FFFF99" size="2"><b><a
							href="home.jsp">&nbsp;&nbsp;HOME&nbsp;&nbsp;</a></b></font></td>
				<td align="center" valign="middle" width="50" height=""><font
					face="tahoma" color="#FFFF99" size="2"><b><a
							href="./SkillReqs">&nbsp;&nbsp;ABILITA'&nbsp;&nbsp;</a></b></font></td>
				<td></td>
				<td align="right" valign="middle" width="200" height=""><font
					face="tahoma" color="#FFFF99" size="2">&nbsp;&nbsp;Benvenuto,
						<%=session.getAttribute("username")%>! <a href="./Logout"><b>LOGOUT&nbsp;&nbsp;</b></a>
				</font></td>
				<%
					}
				%>
				<%
					}
				%>
			</tr>
		</table>
	</div>
	<div align="center">
		<table width="1000" bgcolor="#FFFFFF">
			<tr>
				<td>
					<%
						if (session.getAttribute("user") == null
								|| session.getAttribute("skills") == null) {
							response.sendRedirect("home.jsp");
						} else {
							User u = (User) session.getAttribute("user");
							List<Skill> skills = (LinkedList<Skill>) session
									.getAttribute("skills");
							List<Feedback> feedbacks = (LinkedList<Feedback>) session
									.getAttribute("feedbacks");
					%>
					<table border="1" bordercolor="#0B0B44">
						<tr>
							<td align="center" bgcolor="#5588FF"><font face="tahoma"
								size="3" color="white"><b>PROFILO</b></font></td>
						</tr>
						<tr>
							<td align="center">
								<table>
									<tr>
										<td align="right" width="235"><font face="tahoma"
											size="2"><b>Username</b></font></td>
										<td width="215"><font face="tahoma" size="2"><%=u.getUsername()%></font></td>
									</tr>
									<tr>
										<td align="right" width="235"><font face="tahoma"
											size="2"><b>E-Mail</b></font></td>
										<td width="215"><font face="tahoma" size="2"><%=u.getEmail()%></font></td>
									</tr>
									<tr>
										<td align="right" width="235"><font face="tahoma"
											size="2"><b>Cognome</b></font></td>
										<td width="215"><font face="tahoma" size="2"><%=u.getSurname()%></font></td>
									</tr>
									<tr>
										<td align="right" width="235"><font face="tahoma"
											size="2"><b>Nome</b></font></td>
										<td width="215"><font face="tahoma" size="2"><%=u.getName()%></font></td>
									</tr>
									<tr>
										<td align="right" width="235"><font face="tahoma"
											size="2"><b>Data di Nascita (AAAA-MM-GG)</b></font></td>
										<td width="215"><font face="tahoma" size="2"> <%
 	if (u.getBirth() != null) {
 %><%=u.getBirth()%> <%
 	}
 %>
										</font></td>
									</tr>
									<tr>
										<td align="right" width="235"><font face="tahoma"
											size="2"><b>Indirizzo</b></font></td>
										<td width="215"><font face="tahoma" size="2"> <%
 	if (u.getAddress() != null) {
 %><%=u.getAddress()%> <%
 	}
 %>
										</font></td>
									</tr>
									<tr>
										<td align="right" width="235"><font face="tahoma"
											size="2"><b>Abilità</b></font></td>
										<td width="215">
											<%
												for (Skill s : skills) {
											%><font face="tahoma" size="2"><%=s.getName()%></font><br>
											<%
												}
											%>
										</td>
									</tr>
								</table>
							</td>
						</tr>
					</table> <br>
				<font face="tahoma" size="2"><a
						href="edit.jsp?password=<%=u.getPassword()%>&email=<%=u.getEmail()%>&name=<%=u.getName()%>&surname=<%=u.getSurname()%>&birth=<%=u.getBirth()%>&address=<%=u.getAddress()%>"
						style="color: blue; text-decoration: underline">Modifica
							profilo</a></font> <br> <font face="tahoma" size="2"><a
						href="./ManageSkills"
						style="color: blue; text-decoration: underline">Gestisci
							abilità</a></font><br>
				<br>
					<table border="1" bordercolor="#0B0B44">
						<tr>
							<td align="center" bgcolor="#5588FF"><font face="tahoma"
								size="3" color="white"><b>FEEDBACK RICEVUTI</b></font></td>
						</tr>
						<tr>
							<td align="center">
								<%if (feedbacks.isEmpty()) {%>
								<font face="tahoma" size="2">Non è presente nessun feedback</font>
								<%} else {%>
									<table>
										<tr>
											<td align="center" width="50"><font face="tahoma"
												size="2"><b>VOTO</b></font></td>
											<td align="center" width="200"><font face="tahoma"
												size="2"><b>COMMENTO</b></font></td>
										</tr>
										<%
											for (Feedback f : feedbacks) {
										%>
												<tr>
													<td align="center" width="50"><font face="tahoma"
														size="2"><%=f.getEvaluation()%></font></td>
													<td align="center" width="200"><font face="tahoma"
														size="2"><%=f.getComment()%></font></td>
												</tr>
										<%
											}
										%>
									</table>
								<%}%>
							</td>
						</tr>
					</table> <%
 	session.removeAttribute("user");
 		session.removeAttribute("skills");
 		session.removeAttribute("feedbacks");
 	}
 %>
				</td>
				<%
					if (session.getAttribute("username") == null) {
						response.sendRedirect("home.jsp");
					} else {
				%>
				<td valign="top" width="250" bgcolor="E3E8F2"></td>
				<%
					}
				%>
			</tr>
		</table>
	</div>
	<div align="center">
		<table width="1000" bgcolor="#4956B1">
			<tr>
				<td align="center" valign="middle" height=""><font
					face="tahoma" size="2" color="#FFFF99">Copyright © 2012-2013
						&nbsp;&nbsp; Eric De Marco - Giulia Busnelli &nbsp; Tutti i
						diritti riservati</font></td>
			</tr>
		</table>
	</div>
</body>
</html>